import request from '@/utils/request';
import type { ResponseData } from '@/utils/types.d';
import { SUCCESS_CODE } from '@/utils/types.d';
import type { AnalysisResult, OverviewResult } from './types';

export async function getVisualOverview(
  lng: number,
  lat: number,
): Promise<{
  success: boolean;
  message: string;
  data: OverviewResult;
}> {
  const res: ResponseData<OverviewResult> = await request(`/api/visual/v1.0.0/overview`, {
    params: { lng, lat },
  });
  if (res?.code === SUCCESS_CODE) return { success: true, message: '获取成功', data: res.data };
  return { success: false, message: res?.message || '获取失败', data: res?.data };
}

export async function getVisualAnalysis(): Promise<{
  success: boolean;
  message: string;
  data: AnalysisResult;
}> {
  const res: ResponseData<AnalysisResult> = await request(`/api/visual/v1.0.0/analysis`);
  if (res?.code === SUCCESS_CODE) return { success: true, message: '获取成功', data: res?.data };
  return { success: false, message: res?.message || '获取失败', data: res?.data };
}
